package com.example.code.juc;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 1; i <= 6; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName()+"国被灭了");
                countDownLatch.countDown();
            }, CountryEnum.foreachCountryEnum(i).getMessage()).start();
        }

        countDownLatch.await();
        System.out.println("秦灭六国，一统华夏");
    }
}
